#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "
INSERT INTO hive.edu_online_ads.ads_visit_consult_data_count
SELECT
    "day",
    "month",
    quarter,
    "year",
    visit_person,0
    visit_dialogue,
    visit_ip
FROM hive.edu_online_dws.dws_visit_consult_data_count
WHERE group_type ='day' or group_type ='month'or group_type ='quarter'or group_type ='year';

INSERT INTO hive.edu_online_ads.ads_visit_consult_data_area_count
SELECT
    "day",
    "month",
    quarter,
    "year",
    country,
    province,
    city,
    visit_person,
    visit_dialogue,
    visit_ip
FROM hive.edu_online_dws.dws_visit_consult_data_count
WHERE group_type ='day' or group_type ='month'or group_type ='quarter'or group_type ='year'
or group_type = 'day_country'or group_type = 'day_province'or group_type = 'day_city'
or group_type = 'month_country'or group_type = 'month_province'or group_type = 'month_city'
or group_type = 'quarter_country'or group_type = 'quarter_province'or group_type = 'quarter_city'
or group_type = 'year_country'or group_type = 'year_province'or group_type = 'year_area';


INSERT INTO hive.edu_online_ads.ads_visit_consult_data_origin_channel_count
SELECT
    "day",
    "month",
    quarter,
    "year",
    origin_channel,
    visit_person,
    visit_dialogue,
    visit_ip
FROM hive.edu_online_dws.dws_visit_consult_data_count
WHERE group_type ='day' or group_type ='month'or group_type ='quarter'or group_type ='year'
or group_type = 'day_origin_channel' or group_type = 'month_origin_channel'or group_type = 'quarter_origin_channel'or group_type = 'year_origin_channel';


INSERT INTO hive.edu_online_ads.ads_visit_consult_data_seo_source_count
SELECT
    "day",
    "month",
    quarter,
    "year",
    seo_source,
    visit_person,
    visit_dialogue,
    visit_ip
FROM hive.edu_online_dws.dws_visit_consult_data_count
WHERE group_type ='day' or group_type ='month'or group_type ='quarter'or group_type ='year'
or group_type = 'day_seo_source' or group_type = 'month_seo_source'or group_type = 'quarter_seo_source'or group_type = 'year_seo_source';


INSERT INTO hive.edu_online_ads.ads_visit_consult_data_from_url_count
SELECT
    "day",
    "month",
    quarter,
    "year",
    from_url,
    visit_person,
    visit_dialogue,
    visit_ip
FROM hive.edu_online_dws.dws_visit_consult_data_count
WHERE group_type ='day' or group_type ='month'or group_type ='quarter'or group_type ='year'
or group_type = 'day_from_url' or group_type = 'month_from_url'or group_type = 'quarter_from_url'or group_type = 'year_from_url';


INSERT INTO hive.edu_online_ads.ads_visit_consult_rate_count
SELECT
    "day",
    "month",
    quarter,
    "year",
    country,
    province,
    city,
    country_consult_rate,
    province_consult_rate,
    city_consult_rate
FROM hive.edu_online_dws.dws_visit_consult_data_count
WHERE group_type ='day' or group_type ='month'or group_type ='quarter'or group_type ='year'
or group_type = 'day_country'or group_type = 'day_province'or group_type = 'day_city'
or group_type = 'month_country'or group_type = 'month_province'or group_type = 'month_city'
or group_type = 'quarter_country'or group_type = 'quarter_province'or group_type = 'quarter_city'
or group_type = 'year_country'or group_type = 'year_province'or group_type = 'year_area';
"